<template>
	<div>
		<script id="editor" type="text/plain"></script>
	</div>
</template>
<script>
	import '../../../static/UE/ueditor.config.js';
	import '../../../static/UE/ueditor.all.min.js';
	import '../../../static/UE/lang/zh-cn/zh-cn.js';
	import '../../../static/UE/ueditor.parse.min.js';
	export default {
		name: 'UE',
		data() {
			return {
				editor: null
			}
		},
		props: {
			defaultMsg: {
				type: String
			},
			config: {
				type: Object
			},
			height: 300
		},
		mounted() {
			const _this = this;
			this.editor = UE.getEditor('editor', this.config); // 初始化UE
			this.editor.addListener("ready", function() {
				_this.editor.setContent(_this.defaultMsg); // 确保UE加载完成后，放入内容。
				_this.editor.setHeight(this.height);
			});
		},
		methods: {
			getUEContent() { // 获取内容方法
				return this.editor.getContent()
			},
			setUEContent(content) { // 获取内容方法
				return this.editor.setContent(content);
			}
		},
		destroyed() {
			this.editor.destroy();
		},
		watch: {
			defaultMsg(val) {
				this.editor.setContent(this.defaultMsg);
			}
		}
	}
</script>